<template>
    <div>
      <!-- 计数器 -->
      <div class="mui-numbox" data-numbox-min='1'>
          <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
          <input id="test" class="mui-input-numbox" type="number" value="1" ref='currentNumber' @change = "changeCount" />
          <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
     </div>
    </div>
</template>

<script>
// 需要初始化引入mui.js才能加减
import mui from '../../lib/mui/js/mui.min.js'
export default {
    // 初始化mui
    mounted(){
        mui(".mui-numbox").numbox();
    },
    methods:{
        // 获取当前的value值
    //    this.$refs.currentNumber.value 接收父组件传递过来的值
    changeCount(){
        this.$emit("sendCount",parseInt(this.$refs.currentNumber.value))
    }
    },
    props: ["max"],
    watch:{
       max :function(newVal,oldVal){
           mui(".mui-numbox").numbox().setOption("max",newVal);
       } 
    }
}
</script>
<style lang="sass" scoped>


</style>

